#ifndef CONTROLLER_H
#define CONTROLLER_H

#include <lua.hpp>

#include <event/events.h>
#include <base/directorymanager.h>
#include <base/stage.h>

#pragma comment (lib, "lua5.1.lib")

#define STAGE_NEW  0
#define STAGE_LOAD 1
#define STAGE_SAVE 2

const char * const STAGE_FILE_EVENT = "STAGE_FILE_EVENT";
class StageFileEvent : public events::Event{
public:
  StageFileEvent(long t, std::string s) : events::Event(STAGE_FILE_EVENT, events::APP_QUEUE) {_t = t; filename = s;};
  long action() {return _t;};
  std::string file() {return filename;};
  Event * copy() const {StageFileEvent * e = new StageFileEvent(_t, filename); return e;};
private:
  long _t;
  std::string filename;
};

class Controller {
public:
  Controller();
  ~Controller();
  int loadModules();
  int loadStage(std::string name);
  int saveStageToFile(std::string filename);
  int newStage();

  Stage * stage;

private:
  lua_State * L;
  DirectoryManager dm;
  void _clean();
  
};

#endif
